package com.jlq.dao;

import com.jlq.pojo.Investor;
import com.jlq.pojo.Stock;
import com.jlq.vo.InvestorVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface InvestorDao {

    //全查
    List<InvestorVo> getAllInvestor(@Param("field") String field, @Param("type") String type, @Param("name")String name);

    //添加股民表
    int insertInvestor(InvestorVo investorVo);

    //查询是否有此股票代码和股票名称
    Stock selectCodeAndName(Stock stock);

    //添加股票表
    int insertStock(Stock stock);

    //添加关系表
    int insertRea(@Param("investorId")Integer investorId ,@Param("stockId")Integer stockId);


    //根据id获取股民表信息
    @Select("select * from t_investor where id = #{value}")
    InvestorVo queryInvestorById(Integer id);

    //根据股民id获取已有的股票信息
    @Select("select s.id,code,`name` from t_my_stock r\n" +
            "left join t_stock s on r.stock_id = s.id where r.my_id = #{value}")
    List<Stock> queryStockById(Integer id);

    //删除修改页面的已有股票
    @Delete("delete from t_my_stock where my_id = #{id} and stock_id = #{stockId}")
    int deleteInvestorStock(@Param("id") Integer id, @Param("stockId")Integer stockId);

    //修改股民表
    int updateInvestor(Investor investor);
}
